var localDB = require("../../../data/localData.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var idx = options.idx;
        var dataItem = localDB.dataList[idx];
        // console.log(" dataItem = " + dataItem);
        this.setData({ holder: dataItem });

        this.setData({ idx: idx });


        var collectionList = wx.getStorageSync("collectionList");

        if (collectionList) {
            console.log("collectionList true...");
            var isCollected = collectionList[this.data.idx];
            this.setData({ ccc: isCollected });
        } else {
            collectionList = {}
            console.log("collectionList false ...");
            collectionList[this.data.idx] = false;
            wx.setStorageSync("collectionList", collectionList);
            console.log(collectionList);
        }

    },

    onCollectionTap: function () {
        console.log("onCollectionTap >>");
        var collectionList = wx.getStorageSync("collectionList");
        var isCollected = collectionList[this.data.idx];
        console.log("isCollected ==" + isCollected);
        isCollected = !isCollected;
        this.setData({ ccc: isCollected });
        collectionList[this.data.idx] = isCollected;
        wx.setStorageSync("collectionList", collectionList);

        // wx.showToast({
        //     title: isCollected ? "收藏成功" : "取消成功"
        // });

        wx.showModal({
            title:"haha"
        });

      

    },

    onMusicTap(){
        wx.playBackgroundAudio({
            dataUrl: "http://ws.stream.qqmusic.qq.com/C100003507bR0gDKBm.m4a?fromtag=38",
            title: "夜夜夜夜-齐秦",
            coverImg: "http://y.gtimg.cn/music/photo_new/T002R150x150M000001TEc6V0kjpVC.jpg?max_age=2592000"
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }


})